package com.zymail.controller;

import com.zymail.bean.ZyGood;
import com.zymail.service.ZyGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/good")
public class GoodController extends BaseController{
    @Autowired
    public ZyGoodService goodService;

    /**
     * 返回分类列表的所有list
     * @return
     */
    @GetMapping("/getall")
    public List<ZyGood> getSortedList(){
        return goodService.getSortedGood();
    }

    /**
     * 返回一个商品的信息
     * @param id
     * @return
     */
    @GetMapping("/getone/{id}")
    public ZyGood getOne(@PathVariable("id") Integer id){
        return goodService.getById(id);
    }


}
